﻿using MaterialSkin;
using MaterialSkin.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Materialize
{
    public partial class Form1 : MaterialForm
    {
        private readonly MaterialSkinManager materialSkinManager;
        private FormStyle formStyle;

        public Form1()
        {
            InitializeComponent();

            materialSkinManager = MaterialSkinManager.Instance;
            initForm();
        }
        /// <summary>
        /// 初始化窗体
        /// </summary>
        private void initForm()
        {
            materialSkinManager.AddFormToManage(this);
            formStyle = new FormStyle(materialSkinManager);

            headerTrackBar.Maximum = formStyle.GetPrimary().Count;
            headerTrackBar.Value = formStyle.Header;

            bodyTrackBar.Maximum = formStyle.GetPrimary().Count;
            bodyTrackBar.Value = formStyle.Body;

            AccTrackBar.Maximum = formStyle.GetAccent().Count;
            AccTrackBar.Value = formStyle.Acc;

            fontColorBtn.Text = formStyle.Text == 0 ? "黑" : "白";

            materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
        }

        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            
        }
        

        private void headerTrackBar_Scroll(object sender, EventArgs e)
        {
            formStyle.Header = headerTrackBar.Value - 1;
        }

        private void bodyTrackBar_Scroll(object sender, EventArgs e)
        {
            formStyle.Body = bodyTrackBar.Value - 1;
        }

        private void skinTrackBar1_Scroll(object sender, EventArgs e)
        {
            formStyle.Acc = AccTrackBar.Value - 1;
        }

        private void fontColorBtn_Click(object sender, EventArgs e)
        {
            fontColorBtn.Text = fontColorBtn.Text == "黑" ? "白" : "黑";
            formStyle.Text = fontColorBtn.Text == "黑" ? 0 : 1;
        }

        private void downloadList_SizeChanged(object sender, EventArgs e)
        {
            int _Count = downloadList.Columns.Count;
            int _Width = downloadList.Width;
            foreach (ColumnHeader ch in downloadList.Columns)
            {
                ch.Width = _Width / _Count;
            }
        }
    }
}
